package com.wy2cloud.core.date;


/**
 * 时间间隔
 * @author WYY
 *@version 2015-11-13
 */
public class TimeSpan {

	/**
	 * 返回时间间隔 ，timespan=dt1-dt2
	 * @param dt1
	 * @param dt2
	 * @return
	 */
	public static TimeSpan Substract(DateTime dt1,DateTime dt2){
		return new TimeSpan(dt1.getTime()-dt2.getTime());
	}
	
	/**
	 * 把DateTime转换为TimeSpan
	 * @param dateTime
	 * @return
	 */
	public static TimeSpan parse(DateTime dateTime){
		return new TimeSpan(dateTime.getTime());
	}
	
	
	/**
	 * 毫秒周期�?
	 */
	private long ticks;
	
	
	public long getTicks() {
		return ticks;
	}


	public TimeSpan(long millis){
		this.ticks=millis;
	}
	
	
	/**
	 * 返回毫秒�?
	 * @return
	 */
	public double getTotalMilliseconds(){
		return this.ticks;
	}
	
	public double getTotalseconds(){
		return ((double)this.ticks)/((double)1000);
	}
	
	
	public double getTotalMinutes(){
		return ((double)this.ticks)/((double)(1000*60));
	}
	
	public double getTotalHours(){
		return ((double)this.ticks)/((double)(1000*60*60));
	}
	
	public double getTotalDays(){
		return ((double)this.ticks)/((double)(1000*60*60*24));
	}
}
